package com.kl.model.base;

import com.kl.constant.AttackModel;
import com.kl.enums.Direct;
import com.kl.enums.State;
import com.kl.enums.TankType;
import lombok.AllArgsConstructor;
import lombok.Data;

import static com.kl.enums.State.DEATH;

/**
 * @author CC
 * time 2024-05-14
 * description
 *  抽象攻击类
 */
@Data
@AllArgsConstructor
public abstract class AbstractAttack implements Attack,Runnable,DisposableBean {
    /**
     * 攻击方向
     */
    private Direct direct;
    /**
     * 状态
     */
    private volatile State state;
    /**
     * 初始坐标
     */
    private int x ;
    /**
     * 初始坐标
     */
    private int y;
    /**
     * 攻击速度
     */
    private int speed;

    /**
     * 子弹来源
     */
    private TankType origin;
    public AbstractAttack(){
        this(Direct.UP,State.ALIVE,0,0,AttackModel.DEFAULT_SPEED,null);
    }

    @Override
    public boolean attack(int x, int y, Direct direct, Object object, TankType origin) {
        return false;
    }
    @Override
    public void run() {

    }

    @Override
    public void destroy() {
        this.setState(null);
        this.direct=null;
        this.origin=null;
    }

    @Override
    public boolean isDestroyed() {
        return getState()==null||getState()== DEATH;
    }
}
